<template>
	<view>
		<nav-bar backState="1000" fontColor="#FFF" bgColor="#007aff" :titleCenter="true" title="位置">
		</nav-bar>
		<view class="page-body">
			<view class="page-section page-section-gap">
				<map style="width: 100%; height: 100vh;" :latitude="latitude" :longitude="longitude" :markers="covers"
					@tap="getPosition">
				</map>
			</view>
		</view>
	</view>
</template>


<script>
	export default {
		data() {
			return {
				id: 0, // 使用 marker点击事件 需要填写id
				title: 'map',
				latitude: 39.909,
				longitude: 116.39742,
				covers: [{
					latitude: 39.909,
					longitude: 116.39742,
					iconPath: '/src/static/logo.png'
				}]
			};
		},
		onLoad() {
			this.getLocation()
		},
		methods: {
			getLocation() {
				uni.getLocation({
					type: 'gcj02',
					geocode: true,
					highAccuracyExpireTime: 100,
					success: (res) => {
						this.longitude = res.longitude; // 经度
						this.latitude = res.latitude; // 纬度
						console.log('当前位置的经度：' + res.longitude);
						console.log('当前位置的纬度：' + res.latitude);
						this.covers[0].longitude = this.longitude
						this.covers[0].latitude = this.latitude
						// 仅App端支持 address
						console.log('当前地址：' + res.address);
					}
				});
			},
		

		}
	}
</script>

<style lang="scss">

</style>
